package com.heima.wemedia.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.mapper.WmChannelMapper;
import com.heima.wemedia.service.WmChannelSevice;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 10161
 */
@Service
public class WmChannelServiceImpl extends ServiceImpl<WmChannelMapper, WmChannel> implements WmChannelSevice {

    /**
     * 获取所有频道的业务实现
     *
     * @return
     */
    @Override
    public ResponseResult getChannel() {
        //1.直接获取数据库中的所有channel的数据
        List<WmChannel> channelList = list();
        //2.对这个list做预见性判断，判断是否为空
        if (channelList.isEmpty()) {
            return ResponseResult.errorResult(AppHttpCodeEnum.DATA_NOT_EXIST, "数据不存在");
        }
        //3.对查询到的数据进行封装，返回给前端显示
        return ResponseResult.okResult(channelList);
    }
}
